@stylable/runtime
@stylable/runtime
provides the utility that is used to create the stylesheet functions that apply classNames
and states
to the DOM. It also exposes an optional DOM renderer that is responsible for loading CSS in its correct order.
End-users will usually not add this package directly as a dependency themselves, and would instead receive it as a dependency of their chosen integration (e.g. @stylable/webpack-plugin
).
Usage
@stylable/runtime
exposes two methods, Stylesheet
and Renderer
.
Stylesheet
The stylesheet function is returned when importing a Stylable stylesheet. It is used for creating the DOM-attributes required for CSS to be applied.
style(className: string, states?: StateMap, props: InheritedAttributes)
Argument | Type | Description | Required |
---|
className | string | className to be namespaced | true |
states | StateMap | object containing states and their values | false |
inheritedAttributes | InheritedAttributes | props passed to the root node from the parent component (automatically passing through className and data-* attributes) | false |
import style from './local.st.css';
props = {
className: "app1211903207--root",
"data-app1211903207-propstate": true
}
style('root');
style('root', {localState: true});
style('root', {localState: true}, props);
style.root;
Renderer
Responsible for managing CSS files, linking to the document
and maintaining their correct order in your application.
License
Copyright (c) 2017 Wix.com Ltd. All Rights Reserved. Use of this source code is governed by a BSD license.